﻿Public Class ViewDateWork

    Dim tbl As New DataTable
    Private Sub ViewDateWork_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        loademp()
    End Sub
    Private Sub loaddate()
        cmd.Parameters("@datestart") = dtp.Value
        cmd.Parameters("@dateend") = dtp2.Value
        cmd.Parameters("@empid") = cboemp.SelectedValue
        tbl = cmd.ExecuteDataTable("SELECT wt_date from worktime_tbl WHERE wt_date between @datestart and @dateend and emp_id=@empid")
    End Sub
    Private Sub loademp()
        cboemp.DisplayMember = "emp_name"
        cboemp.ValueMember = "emp_id"
        cboemp.DataSource = cmd.ExecuteDataTable("SELECT emp_id,emp_name FROM employee_tbl")
    End Sub

    Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dtp2.ValueChanged

    End Sub

    Private Sub btnview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnview.Click
        loaddate()
        defaultlbl()
        If tbl.Rows.Count = 0 Then
            MessageBox.Show("No data Please select vailidate start date and end date")
            Exit Sub
        End If
        Dim datevlue As Date = tbl.Rows(1).Item(0)
        For i = 0 To tbl.Rows.Count - 1
            datevlue = tbl.Rows(i).Item(0)

            If datevlue.ToString("dd") = lbl1.Text Then
                lbl1.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl2.Text Then
                lbl2.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl3.Text Then
                lbl3.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl4.Text Then
                lbl4.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl5.Text Then
                lbl5.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl6.Text Then
                lbl6.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl7.Text Then
                lbl7.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl8.Text Then
                lbl8.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl9.Text Then
                lbl9.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl10.Text Then
                lbl10.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl11.Text Then
                lbl11.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl12.Text Then
                lbl12.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl13.Text Then
                lbl13.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl14.Text Then
                lbl14.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl15.Text Then
                lbl15.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl16.Text Then
                lbl16.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl17.Text Then
                lbl17.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl18.Text Then
                lbl18.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl19.Text Then
                lbl19.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl20.Text Then
                lbl20.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl21.Text Then
                lbl21.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl22.Text Then
                lbl22.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl23.Text Then
                lbl23.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl24.Text Then
                lbl24.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl25.Text Then
                lbl25.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl26.Text Then
                lbl26.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl27.Text Then
                lbl27.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl28.Text Then
                lbl28.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl29.Text Then
                lbl29.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl30.Text Then
                lbl30.ForeColor = Color.Blue
            ElseIf datevlue.ToString("dd") = lbl31.Text Then
                lbl31.ForeColor = Color.Blue
            End If
        Next
    End Sub
    Private Sub defaultlbl()
        Try
            For Each Obj As Object In GroupBox1.Controls
                If TypeOf Obj Is Label Then
                    CType(Obj, Label).ForeColor = Color.Black
                End If
            Next
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
    End Sub
    
    Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter

    End Sub
End Class